#include <stdio.h>
#include <signal.h>
#include <unistd.h>

static void handler1(int s);

int main(void)
{
	int i, j;
	sigset_t set, oldset;
	struct sigaction act;

// 	signal(SIGINT, handler1);
	act.sa_handler = handler1;
	act.sa_flags = 0;
	sigemptyset(&act.sa_mask);
	sigaction(SIGINT, &act, NULL);
	// signal(SIGRTMIN+5, handler1);
	sigaction(SIGRTMIN+5, &act, NULL);

	sigemptyset(&set);
	sigaddset(&set, SIGINT);
	sigaddset(&set, SIGRTMIN+5);

	sigprocmask(SIG_BLOCK, &set, &oldset);
	for (i = 0; i < 10; i ++) {
		for (j = 0; j < 5; j++) {
			write(1, "*", 1);
			sleep(1);
		}
		printf("\n");
		// 2号信号驱动进程的运行
		/*
		sigprocmask(SIG_SETMASK, &oldset, NULL);
		pause();
		sigprocmask(SIG_BLOCK, &set, NULL);
		*/
		sigsuspend(&oldset);
	}

	return 0;
}

static void handler1(int s)
{
	write(1, "!", 1);
}

